﻿@model CanDichVu.Db.ThanhVien
@{
    ViewBag.Title = "Thông tin thành viên";
    Layout = "~/Views/Shared/_Layout.cshtml";
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequest"
        //OnBegin = "show_Loading",
    };
}

<div class="page_post_news">
    <div class="page_post_news_left">
        <div class="formdangtin_news">
            <div class="formdangky">
                @using (Ajax.BeginForm("ChangeInfo", "Account", null, ajaxOpts, new { enctype = "multipart/form-data", name = "frm_register", id = "frm_register" }))
                {
                    <h2 class="h2_title_account_login_res">Cập nhật thông tin thành viên</h2>
                    @Html.HiddenFor(model => model.GioiTinh)
                     @Html.HiddenFor(model => model.HinhAnh)
                    @Html.HiddenFor(model => model.TinhThanh)
                    <ul class="formreg">
                        <li></li>
                         <li></li>
                        <li class="warning-area"></li>
                        <li>
                            <label class="left">Tên đăng nhập</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.UserName, new { name = "txt_UserName", @placeholder = "Tên đăng nhập (bắt buộc từ 3 -> 9 ký tự)", value = "", style = "width: 86%;", @disabled="disabled" })
                                <span id="user-result-check"></span>
                            </span>
                        </li>
                        <li><div class="left">Ảnh đại diện</div> <span class="right">
                            <div id="event-logo-upload" style="">
                                </div>
                                <div class="bank_hight_5"></div>
                                <button type="button" class="delete ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary button_remove_img" role="button" aria-disabled="false"><span class="ui-button-icon-primary ui-icon ui-icon-trash"></span><span class="ui-button-text">Xóa file</span></button>
                                <img src="@Model.HinhAnh" id="imageslogo" width="100" height="100" />
                            </span>
                            </li>
                        <li>
                            <label class="left">Email</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.Email, new {@disabled="disabled", name = "txt_email", @placeholder = "Email (bắt buộc)", value = "", style = "width: 86%;" })
                            </span>
                            <a href="javascript:void(0)" class="edit_email_account" onclick="return changeEmail();">
                                <img src="~/Content/images/edit-icon.png" />
                            </a>
                        </li>
                        <li class="line">
                            <label class="left">Họ tên</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.HoTen, new { name = "HoTen", @placeholder = "Họ tên (bắt buộc)", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        <li class="fone_num">
                            <label class="left">Điện thoại</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.DT, new { name = "DT", @placeholder = "Điện thoại (bắt buộc)", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        @* <li class="fone_num"><label class="left">Ngày sinh</label> <span class="right">
                        @Html.TextBoxFor(model => model.NgaySinh, new { name = "NgaySinh", @placeholder = "Ngày sinh", value = "", style = "width: 86%;" })
                    </span>
                    </li>*@
                        <li class="fone_num">
                            <label class="left">Nick Skype</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.Skype, new { name = "Skype", @placeholder = "Nick Skype", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        <li class="fone_num">
                            <label class="left">Nick Yahoo</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.Yahoo, new { name = "Yahoo", @placeholder = "Nick Yahoo", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        <li class="fone_num">
                            <label class="left">Link Face</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.LinkFace, new { name = "LinkFace", @placeholder = "Link FaceBook", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        <li class="line">
                            <label class="left">Công Ty</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.CongTy, new { name = "CongTy", @placeholder = "Tên công ty (bắt buộc)", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        <li><div class="left">Khu vực của bạn</div> <span class="right">
                                <select id="selectCate_tt" class="easyui-combotree" style="width:585px; height:35px;">
                                
                                </select>
                            </span>
                        </li>
                        <li class="line">
                            <label class="left">Địa Chỉ</label>
                            <span class="right">
                                @Html.TextBoxFor(model => model.DiaChi, new { name = "DiaChi", @placeholder = "Địa chỉ (bắt buộc)", value = "", style = "width: 86%;" })
                            </span>
                        </li>
                        
                        <li class="fone_num">
                            <div class="clear"></div>
                            <div class="right">
                                @Html.Partial("_Captcha", new CanDichVU.Models.Captcha())
                                @Html.Partial("_InvisibleCaptcha", new CanDichVU.Models.InvisibleCaptcha())
                            </div>
                        </li>
                        <li class="fone_num"><span class="left">Giới tính : </span> <span class="right">
                            <select id="selectMadel" onchange="selectChangeMadel()">
                                <option value="0">Không muốn công khai ...</option>
                                <option value="1">Nam</option>
                                <option value="2">Nữ</option>
                            </select>
                        </span>
                        </li>
                        <li class="line"><span class="left">&nbsp;</span> <span class="right">
                            <input type="submit" style="border: 0;" onclick="return loadmaskloading();" class="btnsubmit" value="Cập nhật" name=""></span>
                        </li>
                    </ul>
                }
            </div>
        </div>
    </div>
    <div class="page_post_news_right">
        <div class="PannelAccount">
            @Html.Action("PannelAccount", "Account")
        </div>
    </div>
    <div class="clear"></div>
</div>

<link href="~/Scripts/jquery-loadmask/jquery.loadmask.css" rel="stylesheet" />
<link href="~/Scripts/jquery-capslock-detector/css/jquery.capsalerttipsy.css" rel="stylesheet" />
<script src="~/Scripts/jquery-capslock-detector/js/jquery.tipsy.js"></script>
<script src="~/Scripts/jquery-capslock-detector/js/jquery.jccapsalert.js"></script>
<script src="~/Scripts/jquery-loadmask/jquery.loadmask.js"></script>
<link href="~/Scripts/jquery-easyui/themes/metro/easyui.css" rel="stylesheet" />
<script src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
<script src="~/Scripts/fileuploader.js"></script>
<link href="~/Content/fileuploader.css" rel="stylesheet" />

<script type="text/javascript">

    function loadmaskloading() {
        $("html, body").animate({ scrollTop: 100 }, "slow");
        $(".formdangky").mask("Dữ liệu đang xử lý...", 500);

    }

    function selectChangeMadel() {
        var value_nn = $("#selectMadel").val();
        $("#GioiTinh").val(value_nn);
    }

    $(function () {


        //$(".button_remove_img").attr("disabled", "disabled");

        $("#selectMadel").val($("#GioiTinh").val());

        var thumblogo = $("img#imageslogo");
        var buttonlogo = $("#event-logo-upload")[0];
        var uploader = new qq.FileUploader({
            element: buttonlogo,
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            sizeLimit: 2147483647, // max size
            action: '/Post/UploadImagePost',
            multiple: false,
            onSubmit: function (file, extension) {
                //$('div.preview').addClass('loading');
            },
            onComplete: function (id, fileName, responseJSON) {
                //if ($("#HinhAnh").val() != "") {
                //    deletefileUpload();
                //}
                $("#HinhAnh").val(responseJSON.filePath);
                thumblogo.attr('src', responseJSON.filePath);
                thumblogo.css('display', 'block');
                //$(".button_remove_img").removeAttr("disabled");
            }
        });

        $(".button_remove_img").click(function () {
            deletefileUpload();
        });

        var treestt = $('#selectCate_tt').combotree({
            url: '/Post/GetCateTTDorpList',
            onSelect: function (rec) {
                $("#TinhThanh").val(rec.id);
            }
        });

        $('#selectCate_tt').combotree('setValue', $("#TinhThanh").val());

        

    });

    function deletefileUpload() {
        $.ajax({
            type: "POST",
            url: "/Post/DeleteFilePostOnThanhVienCurrent",
            data: { url: $("#HinhAnh").val() }
        }).done(function (msg) {
            var thumblogos = $("img#imageslogo");
            $("#HinhAnh").val(msg.filePath);
            thumblogos.attr('src', msg.filePath);
            thumblogos.css('display', 'block');
            //$(".button_remove_img").attr("disabled", "disabled");
            $(".qq-upload-list").html("");
        });
    }

    function completedAjaxRequest(obj) {
        var returnObj = eval('(' + obj.responseText + ')');
        if (returnObj.Status == "success") {

            makeSccuessHighlight("Cập nhật thông tin thành công");
            $(".formdangky").unmask();

        } else {
            makeErrorHighlight(returnObj.Message);
            $(".formdangky").unmask();
        }
        return false;
    }

    function makeErrorHighlight(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $("html, body").animate({ scrollTop: 100 }, "slow");
        $highlight.delay(4000).fadeOut(500);

    }

    function makeSccuessHighlight(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Thành công: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $("html, body").animate({ scrollTop: 100 }, "slow");
        $highlight.delay(4000).fadeOut(500);

    }

</script>